<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function deepCopy(target){
            if(typeof taget !== 'object'){
                return target
            }
             //三元运算符
            var result= Array.isArray(target) ? {} :[]
        if(Array.isArray(target)){
            for(var k in target){
                result[k] = target[k] 
            }
        } else{
            for(var i = 0 ; i < target.length ; i++){
                result.push(target[i])
            } 
        }
        return result
        }
        var obj1 = {
            name :'hah',
            hobby :'踢毽子'
        }
        var obj2 = deepCopy(obj1)
        console.log( obj2)
       
      
    </script>
</body>
</html>